package vip.xiaonuo.smzq.modular.kcl.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.kcl.entity.Clsp;
import vip.xiaonuo.smzq.modular.kcl.entity.param.ClspParam;
import vip.xiaonuo.smzq.modular.kcl.entity.vo.ClspVo;
import vip.xiaonuo.smzq.modular.kcl.entity.vo.KcclSpJg;
import vip.xiaonuo.smzq.modular.kcl.service.IClspService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 储量审批流程
 *
 * @author sqq
 * @since 2024-04-23
 */
@Api(tags = "储量审批流程")
@RestController
@RequestMapping("/kcl/clsp")
@Validated
public class ClspController {

    @Resource
    private IClspService iClspService;

    /**
     * 添加储量审批流程
     */
    @ApiOperation("添加储量审批流程")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Clsp clsp) {
        iClspService.save(clsp);
        return CommonResult.ok();
    }

    /**
     * 删除储量审批流程
     */
    @ApiOperation("删除储量审批流程")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iClspService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑储量审批流程
     */
    @ApiOperation("编辑储量审批流程")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid ClspVo clsp) {



        iClspService.updateClspVo(clsp);
        return CommonResult.ok();
    }

    /**
     * 储量审批流程分页查询
     */
    @ApiOperation("储量审批流程分页查询")
    @GetMapping("/list")
    public CommonResult<Page<Clsp>> page() {
        return CommonResult.data(iClspService.page(new Clsp()));
    }
    /**
     * 储量审批流程详情分页查询
     */
    @ApiOperation("储量审批流程详情分页查询")
    @GetMapping("/clspVopage")
    public CommonResult<Page<ClspVo>> clspVopage(
            @ApiParam(name = "current", value = "页数", example = "1", required = true)  @RequestParam long current,
            @ApiParam(name = "size", value = "每页数量", example = "20", required = true) @RequestParam long size,
            @ApiParam(name = "nd", value = "年度")  Integer nd,
            @ApiParam(name = "xzqh", value = "行政区划")  String xzqh,
            @ApiParam(name = "tbzt", value = "填报状态（1已填报，0未填报）")  String tbzt,
            @ApiParam(name = "spzt", value = "审核状态(0未审核，1已审核，2.回退修改)")  String spzt
    ) {
        return CommonResult.data(iClspService.clspVopage(current,size,nd,xzqh,tbzt,spzt));
    }

    /**
     * 储量审批结果数量
     */
    @ApiOperation("储量审批结果数量")
    @GetMapping("/getKcclSpJg")
    public CommonResult<KcclSpJg> getKcclSpJg(
           Integer nd, String xzqh
    ) {
        return CommonResult.data(iClspService.getKcclSpJg(nd,xzqh));
    }

    /**
     * 整体同步年报填报审批
     * 当前年度，同步后两年数据
     */
    @ApiOperation("整体同步年报填报审批")
    @GetMapping("/addKcclSpJg{nd}")
    public CommonResult<String> getKcclSpJg(
            @PathVariable("nd")   Integer nd
    ) {
        iClspService.addKcclSpJg(nd);
        return CommonResult.ok();
    }

    /**
     * 判断年报是否有储量审批结果
     */
    @ApiOperation("判断年报是否有储量审批结果：true审批过 false未审批过")
    @PostMapping("/getKcclSpJgCount")
    public CommonResult<Boolean> getKcclSpJgCount(@RequestBody @Valid ClspParam param) {
        return CommonResult.data(iClspService.getKcclSpJgCount(param));
    }
}
